﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;

namespace PGBT
{
    public partial class CauHinhHeThong : Form
    {
        public CauHinhHeThong()
        {
            InitializeComponent();
        }

        private void CauHinhHeThong_Load(object sender, EventArgs e)
        {
            Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            if (configuration.AppSettings.Settings.Count >=2)
            {
                txtDataSource.Text = configuration.AppSettings.Settings["dataSource"].Value;
                txtDbFile.Text = configuration.AppSettings.Settings["initialCatalog"].Value;
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            configuration.AppSettings.Settings.Clear();
            configuration.AppSettings.Settings.Add("dataSource", txtDataSource.Text);
            configuration.AppSettings.Settings.Add("initialCatalog", txtDbFile.Text);
            configuration.Save();
            ConfigurationManager.RefreshSection("appSettings");
            Close();
        }
    }
}
